package net.zjitc.converter;

import org.springframework.core.convert.converter.Converter;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class DateConverter implements Converter<String, Date> {
//    定义日期格式
    private String patten = "yyyy-MM-dd";
    public Date convert(String s) {
        SimpleDateFormat format = new SimpleDateFormat(patten);
        Date date = null;
        try {
             date = format.parse(s);
        } catch (ParseException e) {
            e.printStackTrace();
        }finally {
            return date; //返回date
        }
    }
}
